package Client.GUI;

import Client.GUI.SwingWorkers.CreateTreeWorker;
import Client.Operations.ClientSession;
import Library.Common.GUIOperations;
import Library.Model.User;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Interface extends javax.swing.JFrame {

    /**
     * Creates new form Interface
     */
    
    private Socket connection = null;
    private User user;
    private String localDirectory = "";
    private String serverDirectory = "";
    private ObjectInputStream input;
    private ObjectOutputStream output;
    
    public Interface() {
        initComponents();
        initButtonsDisabled();
        localdirectory_jTextField.setText("/");
        CreateTreeWorker treeWorker = new CreateTreeWorker(input, output, false, "/", clientstatus_jTextPane, localtree_jTree);
        treeWorker.execute();
        remotetree_jTree.setModel(GUIOperations.getTreeFinal("", true, input, output));
    }
    
    private void initButtonsDisabled() {
        connect_jToggleButton.setEnabled(true);
        disconnect_jToggleButton.setEnabled(false);
        uploadfile_jToggleButton.setEnabled(false);
        deletefile_jToggleButton.setEnabled(false);
        downloadfile_jToggleButton.setEnabled(false);
        createdirectory_jToggleButton.setEnabled(false);
        deletedirectory_jToggleButton.setEnabled(false);
        createuser_jToggleButton.setEnabled(false);
        deleteuser_jToggleButton.setEnabled(false);
        remotedirectory_jTextField.setEnabled(false);
        remotetree_jTree.setEnabled(false);
        /*menuBarEditServer.setEnabled(false);
        menuBarEditExecuteCommand.setEnabled(false);
        menuBarEditStopServer.setEnabled(false);*/
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();
        deleteuser_jFrame = new javax.swing.JFrame();
        createuser_jFrame = new javax.swing.JFrame();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        newuser_jCheckBox = new javax.swing.JCheckBox();
        newuser_jButton = new javax.swing.JButton();
        newuser_name_jTextField = new javax.swing.JTextField();
        newuser_password_jTextField = new javax.swing.JTextField();
        newuser_passrepeat_jTextField = new javax.swing.JTextField();
        uploadfile_jToggleButton = new javax.swing.JToggleButton();
        deletefile_jToggleButton = new javax.swing.JToggleButton();
        downloadfile_jToggleButton = new javax.swing.JToggleButton();
        createdirectory_jToggleButton = new javax.swing.JToggleButton();
        deletedirectory_jToggleButton = new javax.swing.JToggleButton();
        createuser_jToggleButton = new javax.swing.JToggleButton();
        deleteuser_jToggleButton = new javax.swing.JToggleButton();
        jLabel1 = new javax.swing.JLabel();
        username_jTextField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        userpass_jPasswordField = new javax.swing.JPasswordField();
        jLabel3 = new javax.swing.JLabel();
        server_jTextField = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        port_jTextField = new javax.swing.JTextField();
        connect_jToggleButton = new javax.swing.JToggleButton();
        disconnect_jToggleButton = new javax.swing.JToggleButton();
        jLabel5 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        clientstatus_jTextPane = new javax.swing.JTextPane();
        jLabel6 = new javax.swing.JLabel();
        localdirectory_jTextField = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        remotedirectory_jTextField = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        localtree_jTree = new javax.swing.JTree();
        jScrollPane3 = new javax.swing.JScrollPane();
        remotetree_jTree = new javax.swing.JTree();
        jLabel8 = new javax.swing.JLabel();
        filedate_jTextField = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        filesize_jTextField = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        filetype_jTextField = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        filepermissions_jTextField = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        visibility_jTextField = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        serverstatus_jTextPane = new javax.swing.JTextPane();
        jMenuBar2 = new javax.swing.JMenuBar();
        jMenu3 = new javax.swing.JMenu();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        javax.swing.GroupLayout deleteuser_jFrameLayout = new javax.swing.GroupLayout(deleteuser_jFrame.getContentPane());
        deleteuser_jFrame.getContentPane().setLayout(deleteuser_jFrameLayout);
        deleteuser_jFrameLayout.setHorizontalGroup(
            deleteuser_jFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        deleteuser_jFrameLayout.setVerticalGroup(
            deleteuser_jFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        createuser_jFrame.setTitle("Crear Usuario");
        createuser_jFrame.setMinimumSize(new java.awt.Dimension(400, 300));
        createuser_jFrame.setResizable(false);

        jLabel14.setText("Usuario:");

        jLabel15.setText("Contraseña:");

        jLabel16.setText("Repita la contraseña:");

        newuser_jCheckBox.setText("Privilegios");
        newuser_jCheckBox.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        newuser_jButton.setText("Crear usuario");

        newuser_name_jTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newuser_name_jTextFieldActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout createuser_jFrameLayout = new javax.swing.GroupLayout(createuser_jFrame.getContentPane());
        createuser_jFrame.getContentPane().setLayout(createuser_jFrameLayout);
        createuser_jFrameLayout.setHorizontalGroup(
            createuser_jFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(createuser_jFrameLayout.createSequentialGroup()
                .addGroup(createuser_jFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(createuser_jFrameLayout.createSequentialGroup()
                        .addGap(48, 48, 48)
                        .addGroup(createuser_jFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel16)
                            .addComponent(jLabel15)
                            .addComponent(jLabel14))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(createuser_jFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(newuser_name_jTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 158, Short.MAX_VALUE)
                            .addComponent(newuser_password_jTextField)
                            .addComponent(newuser_passrepeat_jTextField))
                        .addGap(0, 45, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, createuser_jFrameLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(newuser_jCheckBox, javax.swing.GroupLayout.PREFERRED_SIZE, 380, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, createuser_jFrameLayout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(newuser_jButton)
                .addGap(133, 133, 133))
        );
        createuser_jFrameLayout.setVerticalGroup(
            createuser_jFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(createuser_jFrameLayout.createSequentialGroup()
                .addGap(61, 61, 61)
                .addGroup(createuser_jFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(newuser_name_jTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(createuser_jFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(newuser_password_jTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(createuser_jFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(newuser_passrepeat_jTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(24, 24, 24)
                .addComponent(newuser_jCheckBox)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(newuser_jButton)
                .addContainerGap(31, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        uploadfile_jToggleButton.setText("Subir Fichero");

        deletefile_jToggleButton.setText("Borrar Fichero");

        downloadfile_jToggleButton.setText("Descargar Fichero");

        createdirectory_jToggleButton.setText("Crear Directorio");

        deletedirectory_jToggleButton.setText("Borrar Directorio");

        createuser_jToggleButton.setText("Crear Usuario");
        createuser_jToggleButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                createuser_jToggleButtonActionPerformed(evt);
            }
        });

        deleteuser_jToggleButton.setText("Borrar Usuario");

        jLabel1.setText("Usuario:");

        username_jTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                username_jTextFieldActionPerformed(evt);
            }
        });

        jLabel2.setText("Contraseña:");

        jLabel3.setText("Servidor:");

        server_jTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                server_jTextFieldActionPerformed(evt);
            }
        });

        jLabel4.setText("Puerto:");

        connect_jToggleButton.setText("Conectar");
        connect_jToggleButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                connect_jToggleButtonActionPerformed(evt);
            }
        });

        disconnect_jToggleButton.setText("Desconectar");

        jLabel5.setText("Estado del cliente:");

        clientstatus_jTextPane.setEditable(false);
        jScrollPane1.setViewportView(clientstatus_jTextPane);

        jLabel6.setText("Directorio local:");

        jLabel7.setText("Directorio remoto:");

        localtree_jTree.setAutoscrolls(true);
        jScrollPane2.setViewportView(localtree_jTree);

        jScrollPane3.setViewportView(remotetree_jTree);

        jLabel8.setText("Fecha de modificación:");

        jLabel9.setText("Tamaño (Bytes):");

        jLabel10.setText("Tipo de archivo:");

        jLabel11.setText("Permisos (r,w,x):");

        jLabel12.setText("Visibilidad:");

        jLabel13.setText("Estado del servidor:");

        serverstatus_jTextPane.setEditable(false);
        jScrollPane4.setViewportView(serverstatus_jTextPane);

        jMenu3.setText("Archivo");
        jMenuBar2.add(jMenu3);

        jMenu4.setText("Editar");

        jMenuItem1.setText("jMenuItem1");
        jMenu4.add(jMenuItem1);

        jMenuBar2.add(jMenu4);

        setJMenuBar(jMenuBar2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(username_jTextField)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(userpass_jPasswordField)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(server_jTextField)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(port_jTextField)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(connect_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(disconnect_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(uploadfile_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(deletefile_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(downloadfile_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(createdirectory_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(remotedirectory_jTextField)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(deletedirectory_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(createuser_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(deleteuser_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jScrollPane2)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(localdirectory_jTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGap(230, 230, 230))
                                    .addComponent(jScrollPane3)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel13)
                                .addContainerGap())
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(filedate_jTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(filesize_jTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(filetype_jTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(filepermissions_jTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(visibility_jTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.TRAILING)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(username_jTextField)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(userpass_jPasswordField)
                    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(server_jTextField)
                    .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(port_jTextField)
                    .addComponent(connect_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(disconnect_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(uploadfile_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(deletefile_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(downloadfile_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(createdirectory_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(deletedirectory_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(createuser_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(deleteuser_jToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(localdirectory_jTextField)
                    .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(remotedirectory_jTextField))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(filedate_jTextField)
                    .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(filesize_jTextField)
                    .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(filetype_jTextField)
                    .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(filepermissions_jTextField)
                    .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(visibility_jTextField))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel13)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void connect_jToggleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connect_jToggleButtonActionPerformed
        try {
            // TODO add your handling code here:
            connect_jToggleButton.setSelected(false);
            User new_user = new User(username_jTextField.getText(), new String(userpass_jPasswordField.getPassword().toString()));
            //ClientSession session = new ClientSession(server_jTextField.getText(), Integer.parseInt(port_jTextField.getText()));
            //session.run();
            connection = ClientSession.connect(server_jTextField.getText(), Integer.parseInt(port_jTextField.getText()), clientstatus_jTextPane);
            output = new ObjectOutputStream(connection.getOutputStream());
            input = new ObjectInputStream(connection.getInputStream());
        } catch (IOException ex) {
            Logger.getLogger(Interface.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_connect_jToggleButtonActionPerformed

    private void server_jTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_server_jTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_server_jTextFieldActionPerformed

    private void newuser_name_jTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newuser_name_jTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_newuser_name_jTextFieldActionPerformed

    private void createuser_jToggleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createuser_jToggleButtonActionPerformed
        // TODO add your handling code here:
        createuser_jToggleButton.setSelected(false);
        createuser_jFrame.setVisible(true);
    }//GEN-LAST:event_createuser_jToggleButtonActionPerformed

    private void username_jTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_username_jTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_username_jTextFieldActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Interface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Interface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Interface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Interface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new Interface().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextPane clientstatus_jTextPane;
    private javax.swing.JToggleButton connect_jToggleButton;
    private javax.swing.JToggleButton createdirectory_jToggleButton;
    private javax.swing.JFrame createuser_jFrame;
    private javax.swing.JToggleButton createuser_jToggleButton;
    private javax.swing.JToggleButton deletedirectory_jToggleButton;
    private javax.swing.JToggleButton deletefile_jToggleButton;
    private javax.swing.JFrame deleteuser_jFrame;
    private javax.swing.JToggleButton deleteuser_jToggleButton;
    private javax.swing.JToggleButton disconnect_jToggleButton;
    private javax.swing.JToggleButton downloadfile_jToggleButton;
    private javax.swing.JTextField filedate_jTextField;
    private javax.swing.JTextField filepermissions_jTextField;
    private javax.swing.JTextField filesize_jTextField;
    private javax.swing.JTextField filetype_jTextField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuBar jMenuBar2;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTextField localdirectory_jTextField;
    private javax.swing.JTree localtree_jTree;
    private javax.swing.JButton newuser_jButton;
    private javax.swing.JCheckBox newuser_jCheckBox;
    private javax.swing.JTextField newuser_name_jTextField;
    private javax.swing.JTextField newuser_passrepeat_jTextField;
    private javax.swing.JTextField newuser_password_jTextField;
    private javax.swing.JTextField port_jTextField;
    private javax.swing.JTextField remotedirectory_jTextField;
    private javax.swing.JTree remotetree_jTree;
    private javax.swing.JTextField server_jTextField;
    private javax.swing.JTextPane serverstatus_jTextPane;
    private javax.swing.JToggleButton uploadfile_jToggleButton;
    private javax.swing.JTextField username_jTextField;
    private javax.swing.JPasswordField userpass_jPasswordField;
    private javax.swing.JTextField visibility_jTextField;
    // End of variables declaration//GEN-END:variables
}
